#ifndef SQL_H
#define SQL_H

#include <QtCore>
#include <QDebug>
#include <QSqlDatabase>
#include <QSqlQuery>

class sql
{
public:
    sql(const QString &host, const qint32 &port, const QString &username, const QString &pwd, const QString &db_name);

    ~sql();

    bool insert_user(QString user, QString pwd);

    bool insert_song(QString song_name, QString path);

    bool insert_user_song(QString user, QString song_name);

    std::unordered_map<QString, QString> select_song_name_and_path(QString user);

    bool  delete_song(QString song_name);

    bool is_open() const;

private:
    QString host;
    qint32 port;
    QString username;
    QString pwd;
    QString db_name;

    bool is_open_;

    QSqlDatabase db;
};

#endif // SQL_H
